﻿/* slidebutton.js Addon Nice 2009 */
var expanded = false;
var panelDomElement;
var slider;
var timeout;
var timerlength = 3000; // how long before the menu should time-out!
var slide;

function ShowMenu() 
{
    PreventTimeOut();
    if (!expanded) {
        SetUpAnimation(); // call the function that will make the menu appear            
        expanded = true;
    }
}

function PreventTimeOut(panelbar, args) 
{
    if (timeout) {
        window.clearTimeout(timeout);
    }
}

function HideMenu(panelbar, args) 
{
    timeout = window.setTimeout(
            function() {
            slide.collapse();
            expanded = false;
                        }, timerlength);
}

function cleanSlider() 
{
    if (timeout)
        window.clearTimeout(timeout);
    timeout = null;
    if (expanded) {
        if (slide)
            slide.collapse();
    }
    expanded = false;
}

function SetUpAnimation() {
    //cleanSlider();
    panelDomElement.style.position = "relative";
    var expandAnimation = new Telerik.Web.UI.AnimationSettings({});
    var collapseAnimation = new Telerik.Web.UI.AnimationSettings({});
    slide = new Telerik.Web.UI.jSlide(panelDomElement, expandAnimation, collapseAnimation, false);
    slide.initialize();
    slide.set_direction(Telerik.Web.UI.jSlideDirection.Right);
    slider.onclick = function() 
    {
        panelDomElement.parentNode.style.visibility = "visible";
        panelDomElement.parentNode.style.display = "block";
        if (!expanded) 
        {
            slide.expand();
        }
        else 
        {
            slide.collapse();
        }
        expanded = !expanded;
        return false;
    }
}

